package com.party.core.service.commune.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.commune.CIntegralTypeReadDao;
import com.party.core.dao.write.commune.CIntegralTypeWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.commune.CIntegralType;
import com.party.core.model.commune.CIntegralTypeOutput;
import com.party.core.service.commune.ICIntegralTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: party
 * @description: 积分类型服务实现
 * @author: Hua Qunhao
 * @create: 2019-08-12 14:32
 **/
@Service
public class CIntegralTypeService implements ICIntegralTypeService {
    @Autowired
    private CIntegralTypeReadDao cIntegralTypeReadDao;
    @Autowired
    private CIntegralTypeWriteDao cIntegralTypeWriteDao;


    @Override
    public String insert(CIntegralType cIntegralType) {
        BaseModel.preInsert(cIntegralType);
        BaseModel.preByInfo(cIntegralType.getCreateBy(), cIntegralType);
        boolean result = cIntegralTypeWriteDao.insert(cIntegralType);
        if (result) {
            return cIntegralType.getId();
        }
        return null;
    }

    @Override
    public boolean update(CIntegralType cIntegralType) {
        cIntegralType.setUpdateDate(new Date());
        return cIntegralTypeWriteDao.update(cIntegralType);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return cIntegralTypeWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public CIntegralType get(String id) {
        return cIntegralTypeReadDao.get(id);
    }

    @Override
    public List<CIntegralType> listPage(CIntegralType cIntegralType, Page page) {
        return cIntegralTypeReadDao.listPage(cIntegralType, page);
    }

    @Override
    public List<CIntegralType> list(CIntegralType cIntegralType) {
        return cIntegralTypeReadDao.listPage(cIntegralType, null);
    }

    @Override
    public List<CIntegralType> batchList(Set<String> ids, CIntegralType cIntegralType, Page page) {
        return null;
    }

    @Override
    public List<CIntegralType> webPageList(Map<String, Object> params, Page page) {
        return cIntegralTypeReadDao.webPageList(params, page);
    }

    @Override
    public List<CIntegralTypeOutput> queryMedalListByPmIdAndPartnerId(String cuiPartnerId, String partnerId, String memberId, Page page) {
        return cIntegralTypeReadDao.queryMedalListByPmIdAndPartnerId(cuiPartnerId, partnerId, memberId, page);
    }

    @Override
    public List<CIntegralType> getAllTypes(String pmId) {
        return cIntegralTypeReadDao.getAllTypes(pmId);
    }

    @Override
    public List<CIntegralTypeOutput> queryMedalListByPmIdAndPartnerId2(String cuiPartnerId, String partnerId, String memberId, Page page) {
        return cIntegralTypeReadDao.queryMedalListByPmIdAndPartnerId2(cuiPartnerId,partnerId,memberId,page);
    }

    @Override
    public CIntegralType getIntegralTypeByName(String name) {
        return cIntegralTypeReadDao.getIntegralTypeByName(name);
    }
}
